package swind.web.dao.imp;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import swind.web.dao.IScoreDao;
import swind.web.dao.base.BaseHibernateDAO;
import swind.web.entities.ExamScore;

@Repository(value="scoreDaoImp")
public class ScoreDaoImp extends BaseHibernateDAO<ExamScore> implements IScoreDao{

	@SuppressWarnings("unchecked")
	@Override
	public ExamScore getScore(int subId, String userId) {
		ExamScore score = new ExamScore();
		String hql="select * from exam_score where user_id = '"+userId+"' and subject_id = "+subId+";";
		List<Object[]> list = this.createSqlQuery(hql).list();
		if(list.isEmpty()){
			return null;
		}
		score.setId((Integer)list.get(0)[0]);
		/*score.setUserId((String)list.get(0)[1]);
		score.setSubjectId((Integer)list.get(0)[2]);
		score.setExamTime((Date)list.get(0)[3]);
		score.setScore((double)list.get(0)[4]);*/
		return score;
		
	}

}
